package translinkApp.Adaptors.Contacts;

import translinkApp.DataTypes.Contacts.ContactAddress;
import translinkApp.DataTypes.Contacts.ContactAddressList;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ContactAddressListAdaptor extends BaseAdapter {

	private Context context;
	private ContactAddressList contactAddresses;

	public ContactAddressListAdaptor(final Context context,
			ContactAddressList contactAddresses) {

		this.contactAddresses = contactAddresses;
		this.context = context;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ContactAddress c = (ContactAddress) getItem(position);

		// if the array item is null, nothing to display, just return null
		if (c == null) {
			return null;
		}

		TextView contactName = new TextView(context);
		contactName.setTextSize(22f);

		contactName.setText(c.getFullAddress());
		contactName.setPadding(5, 10, 5, 10);
		contactName.setTextColor(Color.BLACK);

		return contactName;
	}

	@Override
	public int getCount() {

		return contactAddresses.size();
	}

	@Override
	public Object getItem(int position) {

		return contactAddresses.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

}